package com.tcd.outRisk.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tcd.outRisk.entity.ClaimMainInfo;
import com.tcd.outRisk.service.ClaimMainInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 赔案主档表 前端控制器
 * </p>
 *
 * @author Jarle
 * @since 2021-05-22
 */
@RestController
@RequestMapping("/ClaimmainInfo")
@CrossOrigin
public class ClaimMainInfoController {
    @Autowired
    ClaimMainInfoService clainmain;

    @RequestMapping("/Clainmainall")
    public Map<String, Object> mainlist(int page, int pagesize) {
        Map<String, Object> map = new HashMap<>();
        List<ClaimMainInfo> list = clainmain.list();
        map.put("count", list.size());
        List<ClaimMainInfo> listsplice = clainmain.CLainmainlistsplice(page, pagesize);
        map.put("list", listsplice);
        return map;
    }

    @RequestMapping("/Clainmainedit")
    public boolean mainedit(@RequestBody ClaimMainInfo mainInfo) { //通过CLaimMainInfo的ID来修改
        return clainmain.updateById(mainInfo);
    }

    @RequestMapping("/Clainmainlist")
    public List<ClaimMainInfo> Clainmainlist(String uid) {
        return clainmain.Clainmainlist(uid);
    }

    /**
     * 方法描述
     *
     * @param clainmainid
     * @description:根据赔案号查询对应的信息
     * @return: ClaimMainInfo
     * @author: daixingyu
     * @date: 2021-05-28  10:02
     */
    @RequestMapping("/Claimmainone")
    public ClaimMainInfo Clainmainone(String clainmainid) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("claimMain_Id", clainmainid);
        return clainmain.getOne(wrapper);
    }

    //改变赔案的状态
    @RequestMapping("/Claimmainupdatestatus")
    public boolean Clainmainupdatestatus(String ClaimMainId, String ClaimMainstatus) {
        return clainmain.Clainmainupdatestatus(ClaimMainId, ClaimMainstatus);
    }

    @RequestMapping("/getClaimMainone")
    public ClaimMainInfo getClaimmainone(String claimmainid) {
        return clainmain.getClaimmainone(claimmainid);
    }
}

